<?php
/*
|--------------------------------------------------------------------------
| Web Routes: Namespace Console
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use Illuminate\Contracts\Routing\Registrar as RouteRegisterContract;

Route::domain('console.'.env('APP_DOMAIN'))->namespace('Console')->group(function (RouteRegisterContract $route) {
    $route->middleware('normal')->group(function (RouteRegisterContract $route) {
        $route->get('/', 'IndexController@root')->name('console/root');
    });

    $route->middleware('user.auth')->group(function (RouteRegisterContract $route) {
        $route->group(['prefix' => '/index'], function (RouteRegisterContract $route) {
            Route::get('/index', 'IndexController@index')->name('console/index');
        });

        $route->group(['prefix' => '/project'], function (RouteRegisterContract $route) {
            $route->get('/index', 'ProjectController@index')->name('project/index');

            $route->get('/add', 'ProjectController@add')->name('project/add');

            $route->get('/view', 'ProjectController@view')->name('project/view');
        });

        $route->group(['prefix' => '/category'], function (RouteRegisterContract $route) {
            $route->get('/index', 'CategoryController@index')->name('category/index');

            $route->get('/add', 'CategoryController@add')->name('category/add');

            $route->get('/view', 'CategoryController@view')->name('category/view');
        });

        $route->group(['prefix' => '/api'], function (RouteRegisterContract $route) {
            $route->get('/index', 'ApiController@index')->name('api/index');

            $route->get('/add', 'ApiController@add')->name('api/add');

            $route->get('/view', 'ApiController@view')->name('api/view');
        });

        $route->group(['prefix' => '/issue'], function (RouteRegisterContract $route) {
            $route->get('/index', 'IssueController@index')->name('issue/index');
        });

        $route->group(['prefix' => '/userlog'], function (RouteRegisterContract $route) {
            $route->get('/index', 'LogController@index')->name('userlog/index');
        });
    });
});

Route::domain('api.console.'.env('APP_DOMAIN'))->namespace('Console')->group(function (RouteRegisterContract $route) {

    $route->middleware('api.user.auth')->group(function (RouteRegisterContract $route) {
        $route->group(['prefix' => '/project'], function (RouteRegisterContract $route) {
            $route->post('/add', 'ProjectController@add');

            $route->post('/edit', 'ProjectController@edit');

            $route->post('/del', 'ProjectController@del');
        });

        $route->group(['prefix' => '/category'], function (RouteRegisterContract $route) {
            $route->post('/add', 'CategoryController@add');

            $route->post('/edit', 'CategoryController@edit');

            $route->post('/del', 'CategoryController@del');
        });

        $route->group(['prefix' => '/api'], function (RouteRegisterContract $route) {
            $route->post('/add', 'ApiController@add');

            $route->post('/edit', 'ApiController@edit');

            $route->post('/del', 'ApiController@del');
        });

        $route->group(['prefix' => '/issue'], function (RouteRegisterContract $route) {
            $route->post('/edit', 'IssueController@edit');
        });

        $route->group(['prefix' => '/inputparam'], function (RouteRegisterContract $route) {
            $route->post('/del', 'InputController@del');
        });

        $route->group(['prefix' => '/outputparam'], function (RouteRegisterContract $route) {
            $route->post('/del', 'OutputController@del');
        });

        $route->group(['prefix' => '/apierror'], function (RouteRegisterContract $route) {
            $route->post('/del', 'ApiErrorController@del');
        });
        
        $route->group(['prefix' => '/commonparam'], function (RouteRegisterContract $route) {
            $route->post('/del', 'CommonParamController@del');
        });

        $route->group(['prefix' => '/errorcode'], function (RouteRegisterContract $route) {
            $route->post('/del', 'ErrorCodeController@del');
        });

        $route->group(['prefix' => '/projecthistory'], function (RouteRegisterContract $route) {
            $route->post('/edit', 'ProjectHistoryController@edit');

            $route->post('/del', 'ProjectHistoryController@del');
        });
    });
});
